#!usr/bin/env python  
# -*- coding:utf-8 _*-
""" 
@author:robot
@file: case_data_generate_base.py 
@version:
@time: 2022/03/15 
"""
from TapClientCaseData.ColumnGenerateData.dynamic.base import base00_common
from TapUtil.operatefile.use_yaml import read_yaml
from TapUtil.operatefile.path_operate import *

from pprint import pprint
import inspect

CASE_GENERATE_DATA_PATH = get_grandfather_dirname(get_realpath(__file__))

# base
CASE_GENERATE_BASE = path_joint(CASE_GENERATE_DATA_PATH, 'base')
# cloud
CASE_GENERATE_CLOUD = path_joint(CASE_GENERATE_DATA_PATH, 'cloud')

# generate file
__CASE_GENERATE_GENERATE_FILE = path_joint(CASE_GENERATE_DATA_PATH, 'generatefile')

# source
CASE_GENERATE_SOURCE = path_joint(__CASE_GENERATE_GENERATE_FILE, 'source')
# target
CASE_GENERATE_TARGET = path_joint(__CASE_GENERATE_GENERATE_FILE, 'target')
# file
_CASE_GENERATE_FILE = path_joint(__CASE_GENERATE_GENERATE_FILE, 'file')
#
# default
DEFAULT = {'GenerateTableRecord': {'demo': None},
           'GenerateCaseData': {'demo': None}, }
MYSQL_GENERATE_STATIC = read_yaml(path_joint(_CASE_GENERATE_FILE, '01mysql.yml'))
ORACLE_GENERATE_STATIC = read_yaml(path_joint(_CASE_GENERATE_FILE, '02oracle.yml'))
MONGODB_GENERATE_STATIC = read_yaml(path_joint(_CASE_GENERATE_FILE, '03mongodb.yml'))
DB2_GENERATE_STATIC = read_yaml(path_joint(_CASE_GENERATE_FILE, '04db2.yml'))
POSTGRES_GENERATE_STATIC = read_yaml(path_joint(_CASE_GENERATE_FILE, '05postgres.yml'))
SQLSERVER_GENERATE_STATIC = read_yaml(path_joint(_CASE_GENERATE_FILE, '06sqlserver.yml'))
DUMMY_GENERATE_STATIC = read_yaml(path_joint(_CASE_GENERATE_FILE, '07dummy.yml'))
MQ_GENERATE_STATIC = read_yaml(path_joint(_CASE_GENERATE_FILE, '08mq.yml'))
KAFKA_GENERATE_STATIC = read_yaml(path_joint(_CASE_GENERATE_FILE, '12kafka.yml'))

# stats
CASE_GENERATE_STATS = read_yaml(path_joint(__CASE_GENERATE_GENERATE_FILE, 'stats_check.yml'))
CASE_GENERATE_STATS_DIR = path_joint(__CASE_GENERATE_GENERATE_FILE, 'stats')

def get_classes(arg):
    classes = {}
    cls_members = inspect.getmembers(arg, inspect.isclass)
    for name, _ in cls_members:
        classes.update({name: _})
    return classes


def static_add_db_info_name(static, kv):
    tmp = static.copy()
    for source_type, name in kv.items():
        tmp.update({'type': source_type})
        tmp.update({'db_info_name': name})
    return tmp
